﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SpeakTechnology.LogicOfBussiness;
namespace SpeakTechnology.Presentation
{
    public partial class Ingress : Form
    {
        public Ingress()
        {
            InitializeComponent();
        }

        private void SAVE_Click(object sender, EventArgs e)
        {

            Validation va = new Validation();
            if (va.Validar_Name_Quantity_Category_Price_brand(BoxName.Text, BoxQuantity.Text, BoxCategory.Text, BoxPrice.Text,boxbrand.Text))
            {
                MessageBox.Show("What Have you  ingress  All the Box Text", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                C_Product p = new C_Product();
                if (p.Save(BoxName.Text, BoxQuantity.Text, BoxCategory.Text, BoxPrice.Text,boxbrand.Text))
                {
                    MessageBox.Show("Saved in the product", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("the product already exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

        private void CLOSE_Click(object sender, EventArgs e)
        {
            this.Close();
        }


       

        private void NEWP_Click_1(object sender, EventArgs e)
        {
            BoxName.Clear();
            BoxQuantity.Clear();
            BoxCategory.Clear();
            BoxPrice.Clear();
            boxbrand.Clear();
        }

        private void BoxName_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Char.IsLetter(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }

        private void BoxCategory_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Char.IsLetter(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }

        private void BoxQuantity_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Char.IsDigit(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }

        private void BoxPrice_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Char.IsDigit(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }

        private void boxbrand_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Char.IsLetter(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }

       
    }
}
